package Text8;

import java.util.*;

public class Main {
    public static int N = 510, M = 100010, n1, n2, m, idx;
    public static int[] h = new int[N], e = new int[M], ne = new int[M];
    public static int[] match = new int[M];
    public static boolean[] st = new boolean[N];
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        n1 = scanner.nextInt();
        n2 = scanner.nextInt();
        m = scanner.nextInt();
        Arrays.fill(h, -1);
        for (int i = 1; i <= m; i++) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            add(a, b);
        }
       int sum=0;
        for (int i = 1; i <=n1 ; i++) {
            Arrays.fill(st,false);
            if(find(i)){
                sum++;
            }
        }
        System.out.println(sum);
    }

    private static boolean find(int x) {
        for (int i = h[x]; i!=-1 ;i=ne[i]) {
            int j=e[i];
            if(!st[j]){
                st[j]=true;
                if(match[j]==0||find(match[j])){
                    match[j]=x;
                    return true;
                }
            }
        }
        return false;
    }

    private static void add(int a, int b) {
        e[idx] = b;
        ne[idx] = h[a];
        h[a] = idx++;
    }
}
